﻿@model GraduationProject.Model.User
@{
    Layout = null;
}

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>用户添加</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link href="~/Content/layui/css/layui.css" rel="stylesheet" />
    <link href="~/Content/css/public.css" rel="stylesheet" />
</head>
<body class="childrenBody">
    <form class="layui-form" style="width:80%;">
        <input type="hidden" class="layui-input userName" name="UserAccount" id="UserAccount" value="@Model.UserAccount" lay-verify="required" placeholder="请输入用户账号">
        <input type="hidden" name="IsDelete" id="IsDelete" value="@Model.IsDelete">
        <input type="hidden" name="UserID" id="UserID" value="@Model.UserID">
        <input type="hidden" name="PhoneState" id="PhoneState" value="@Model.PhoneState">
        <input type="hidden" name="HeadPortrait" id="HeadPortrait" value="@Model.HeadPortrait">
        <input type="hidden" name="EmailState" id="EmailState" value="@Model.EmailState">
        <div class="layui-form-item layui-row layui-col-xs12">
            <label class="layui-form-label">用户名称</label>
            <div class="layui-input-block">
                <input type="text" class="layui-input userName" name="UserName" id="UserName" value="@Model.UserName" lay-verify="required" placeholder="请输入登录名">
            </div>
        </div>

        <div class="layui-form-item layui-row layui-col-xs12">
            <label class="layui-form-label">用户密码</label>
            <div class="layui-input-block">
                <input type="password" class="layui-input userName" name="UserPassWd" id="UserPassWd" value="@Model.UserPassWd" lay-verify="required" placeholder="请输入用户密码">
            </div>
        </div>
        <div class="layui-form-item layui-row layui-col-xs12">
            <label class="layui-form-label">邮箱</label>
            <div class="layui-input-block">
                <input type="text" class="layui-input userEmail" name="UserEmail" id="UserEmail" value="@Model.UserEmail" lay-verify="email" placeholder="请输入邮箱">
            </div>
        </div>
        <div class="layui-form-item layui-row layui-col-xs12">
            <label class="layui-form-label">手机号</label>
            <div class="layui-input-block">
                <input type="text" class="layui-input userEmail" name="UserPhone" id="UserPhone" value="@Model.UserPhone" lay-verify="phone" placeholder="请输入邮箱">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">管理员</label>
            <div class="layui-input-block">
                @if (Model.IsAdmin == 0)
                {
                    <input type="radio" name="IsAdmin" id="IsAdmin" value="0" title="是" checked>
                    <input type="radio" name="IsAdmin" id="IsAdmin" value="1" title="否">
                }
                else
                {
                    <input type="radio" name="IsAdmin" id="IsAdmin" value="0" title="是">
                    <input type="radio" name="IsAdmin" id="IsAdmin" value="1" title="否" checked>
                }
            </div>
        </div>
        <div class="layui-form-item layui-row layui-col-xs12">
            <div class="layui-input-block">
                <button class="layui-btn layui-btn-sm" lay-submit="" lay-filter="addUser">立即修改</button>
                <button type="reset" class="layui-btn layui-btn-sm layui-btn-primary">取消</button>
            </div>
        </div>
    </form>
    <script src="~/Content/layui/layui.js"></script>
    <script>
        layui.use(['form', 'layer'], function () {
            var form = layui.form
            layer = parent.layer === undefined ? layui.layer : top.layer,
                $ = layui.jquery;

            form.on("submit(addUser)", function (data) {
                //弹出loading
                var index = top.layer.msg('数据提交中，请稍候', { icon: 16, time: false, shade: 0.8 });
                // 实际使用时的提交信息
                // $.post("上传路径",{
                //     userName : $(".userName").val(),  //登录名
                //     userEmail : $(".userEmail").val(),  //邮箱
                //     userSex : data.field.sex,  //性别
                //     userGrade : data.field.userGrade,  //会员等级
                //     userStatus : data.field.userStatus,    //用户状态
                //     newsTime : submitTime,    //添加时间
                //     userDesc : $(".userDesc").text(),    //用户简介
                // },function(res){
                //
                // })
                var params = {
                    UserAccount: $("#UserAccount").val(),  //登录名
                    UserPassWd: $("#UserPassWd").val(),  //登录名
                    UserName: $("#UserName").val(),  //登录名
                    UserEmail: $("#UserEmail").val(),  //邮箱
                    UserPhone: $("#UserPhone").val(),  //邮箱
                    IsAdmin: $('#IsAdmin').val(),
                    IsDelete: $("#IsDelete").val(),  //登录名
                    UserID: $("#UserID").val(),  //邮箱
                    PhoneState: $("#PhoneState").val(),  //邮箱
                    HeadPortrait: $("#HeadPortrait").val(),  //邮箱
                    EmailState: $('#EmailState').val()
                    //     userGrade : data.field.userGrade,  //会员等级
                    //     userStatus : data.field.userStatus,    //用户状态
                    //     newsTime : submitTime,    //添加时间
                    //     userDesc : $(".userDesc").text(),    //用户简介
                };
                $.ajax({
                    type: "post",
                    url: "/Admin/AdminUserInfo/AdminUpdate",
                    data: params,
                    dataType: "json",
                    success: function (res) {
                        if (res.code == 0) {
                            layer.msg(res.msg, { icon: 1 });
                            window.parent.location.reload();
                        }
                        else {
                            layer.msg(res.msg, { icon: 2 });
                        }
                    }
                });
                return false;
            })
        });
    </script>
</body>
</html>
